package org.gim.thirdService.KnowledgeService.controller;

import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.rag.content.retriever.EmbeddingStoreContentRetriever;
import dev.langchain4j.service.AiServices;
import lombok.extern.slf4j.Slf4j;
import org.gim.thirdService.AIServiceAPI.service.AisServices;
import org.gim.thirdService.KnowledgeService.req.ChatMessageReq;
import org.gim.thirdService.KnowledgeService.service.ChatService;
import org.gim.thirdService.KnowledgeService.service.DocumentIngestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/chat")
@Slf4j
public class ChatController {

    @Autowired
    private ChatService chatService;

    @Resource
    private DocumentIngestService documentIngestService;

    @Resource
    private OpenAiChatModel openAiChatModel;

    @PostMapping("/ask")
    public String ask(@RequestBody ChatMessageReq chatMessageReq) {
        return chatService.askWithKnowledgeBase(chatMessageReq.getQuestion(),
                chatMessageReq.getKnowledgeCode(),
                chatMessageReq.getUserId());
    }


}
